/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DataAccess;

import Entities.UserEntities;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author vjphl
 */
public class LoginDataAccess {
    ConnectDatabase objCD = new ConnectDatabase();

    private List<UserEntities> userList;

    
    public LoginDataAccess(){
        userList = new ArrayList<UserEntities>();
    }
    
    public boolean CheckLogin(UserEntities userEntities)throws Exception,ClassNotFoundException{
        
        userList.clear();
        objCD.open();
        objCD.setMode(ConnectDatabase.PREPARED);
        objCD.setStatement("Select UserName, [Password] from [User]  where UserName = '"+userEntities.getUserName()+"' and [Password] = '"+userEntities.getPassword()+"'");
        objCD.doQuery();
        if (objCD.rs != null) {
            while (objCD.rs.next()) { 
                return true;
            }
        }
        objCD.close();
        return false;
    }
    
    public List<UserEntities> getUserEntities() {
        return userList;
    }

    public void setUserEntities(List<UserEntities> userEntities) {
        this.userList = userEntities;
    }
}
